package com.mmlc.meimei.lichengkongjian.Adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.androidnetframe.BaseParentActivity;
import com.mmlc.meimei.lichengkongjian.App;
import com.mmlc.meimei.lichengkongjian.R;
import com.mmlc.meimei.lichengkongjian.been.LogisticstBean;
import com.mmlc.meimei.lichengkongjian.customview.MuchOrderItemGroup;
import com.mmlc.meimei.lichengkongjian.shoppingbag.ShoppingBagFragment;

import java.util.List;

public class LogisticsAdapter extends BaseAdapter {

    ViewGroup viewGroup;
    ViewGroup rootView;
    BaseParentActivity activity;
    ShoppingBagFragment fragment;

    List<LogisticstBean> item;

    public LogisticsAdapter(List<LogisticstBean> item) {

        this.item = item;

    }

    @Override
    public int getCount() {
        return item.size();
    }

    @Override
    public LogisticstBean getItem(int i) {
        return item.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    public void remove(int position){
        item.remove(position);
    }
    public void remove(List<LogisticstBean> all){
        item.removeAll(all);
    }
    public boolean haveData( ){
        if(item.size() > 0){
            return true;
        }else{
            return false;
        }
    }
    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = App.layoutInflater.inflate(R.layout.adapter_logistics1, viewGroup, false);
        }
        LogisticstBean bean = item.get(i);

        TextView tv_orderNumber = (TextView) view.findViewById(R.id.tv_orderNumber);
        tv_orderNumber.setText("运单号: "+bean.orderId);

        MuchOrderItemGroup itemGroup = (MuchOrderItemGroup)view.findViewById(R.id.mg_itemGroup);
        itemGroup.addLogisticsItem(bean.itemBeenList);

        return view;
    }
}

